package com.ctshk.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;

/**
 * <p>
 * 操作订单编号生成器工具类
 * </p>
 *
 * @author 胡广
 * @since 2021/2/26
 */
public class OperateNumberGenerateUtil {
    /**
     * 退款编号生成器，规则：TKD+年後2位+月日4位+時分秒6位+2位隨機數字
     *
     * @param nowLocalDateTime
     * @return
     */
    public static String generateRefundNumber(LocalDateTime nowLocalDateTime) {
        String datetime = DateUtil.fmt(nowLocalDateTime, "yyMMddHHmmss");
        String randomNumber = String.valueOf((int) ((Math.random() * 9 + 1) * 10));
        StringBuilder orderNumberSb = new StringBuilder();
        orderNumberSb.append("TKD").append(datetime).append(randomNumber);
        return orderNumberSb.toString().toUpperCase();
    }
}
